package com.zx.erp.market.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zx.erp.market.bean.Custom;
import com.zx.erp.market.mapper.CustomMapper;
import com.zx.erp.market.service.CustomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CustomBizImpl implements CustomService {
    @Autowired
    private CustomMapper cdao;
    @Override
    public PageInfo<Custom> findPageAll(Custom custom, List<Integer> cidList, Integer allot, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        PageInfo<Custom> pageInfo = new PageInfo<>(cdao.findAll(custom, cidList,allot));
        return pageInfo;
    }

    @Override
    public Custom findBy(Integer id) {
        return cdao.selectByPrimaryKey(id);
    }

    @Override
    public boolean addCustom(Custom custom) {
        return cdao.insertSelective(custom);
    }

    @Override
    public boolean editCustom(Custom custom) {
        return cdao.updateByPrimaryKeySelective(custom);
    }

    @Override
    public List<Custom> findAll(Custom custom) {
        return cdao.findAll(custom,null,null);
    }

    @Override
    public List<Custom> findByAddress(List<Integer> cidList) {
        return cdao.findAll(new Custom(),cidList,null);
    }
}
